package com.qianfeng.teachdemo.ui;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.ActionBar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ExpandableListView;
import android.widget.ListView;

import com.qianfeng.teachdemo.R;
import com.qianfeng.teachdemo.ui.jpush.JpushActivity;
import com.qianfeng.teachdemo.ui.pulltorefresh.PullToRefreshActivity;
import com.qianfeng.teachdemo.ui.sharesdk.ShareSDKActivity;
import com.qianfeng.teachdemo.ui.slidingmenu.SlidmingMenuActivity;
import com.qianfeng.teachdemo.ui.touch.TouchActivity;
import com.qianfeng.teachdemo.ui.volley.VolleyActivity;


/**
 */
public class MainActivity extends BaseActivity implements ActionBar.TabListener, AdapterView.OnItemClickListener {
    private String[] contents = {"第一天Volley", "第二天Volley", "第三天PtrViewLibrary(上)", "第三天SlidingMenuLibrary(下)", "第四天(上)ShareSdk", "第四天(下)Jpush", "第五天事件分发与消费"};
    private ListView listView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initSlidingMenu();
        initView();

    }


    public void initView() {
        listView = (ListView) this.findViewById(R.id.main_listview);
        listView.setOnItemClickListener(this);
        listView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1, contents));
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                menu.toggle();
                break;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
        Intent intent = new Intent();
        switch (i) {
            //Volley框架
            case 0:
            case 1:
                intent.setClass(this, VolleyActivity.class);
                startActivity(intent);
                break;
            case 2:
                //上啦刷新下拉加载更多
                intent.setClass(this, PullToRefreshActivity.class);
                startActivity(intent);
                break;
            case 3:
                //侧滑菜单
                intent.setClass(this, SlidmingMenuActivity.class);
                startActivity(intent);
                break;
            case 4:
                //分享
                intent.setClass(this, ShareSDKActivity.class);
                startActivity(intent);
                break;
            case 5:
                //极光推送
                intent.setClass(this, JpushActivity.class);
                startActivity(intent);
                break;
            case 6:
                //触摸时间
                intent.setClass(this, TouchActivity.class);
                startActivity(intent);
                break;
            case 7:
                break;
            case 8:
                break;
            case 9:
                break;
        }

    }

    @Override
    public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {

    }

    @Override
    public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {

    }

    @Override
    public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {

    }


}

